#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@File    : common.py
@Author  : Spring
@Time    : 2024/12/6 10:02
@Desc: PyCharm
"""
from typing import Any


class Result:
    """
    通用返回对象
    """

    def __init__(self, code: int, data: Any = None, message: str = None):
        self.code = code
        self.data = data
        self.message = message

    code: int
    """
    水印结果状态码 0表示成功 非0表示失败
    """

    data: Any = None
    """
    当水印结果为0时，data为水印后的文件对象 反之为空
    """

    message: str = None
    """
    提示信息
    """


class BusinessInput:
    """
    用户自定义水印输入
    """

    user: str
    """
    水印内容用户信息
    """

    ip: str
    """
    水印内容IP
    """

    charset: str
    """
    字符集
    """

    api_customize_watermark_content: str
    """
    用户调用的自定义水印内容
    优先级比策略下发的内容高
    """

    def __init__(self, user: str, ip: str, api_customize_watermark_content: str = None, charset: str = "UTF-8"):
        BusinessInput.__params_validate(ip, user)
        self.user = user
        self.ip = ip
        self.api_customize_watermark_content = api_customize_watermark_content
        self.charset = charset

    @classmethod
    def __params_validate(cls, user: str, ip: str):
        """
        参数校验
        :param user: 水印内容用户信息
        :param ip: 水印内容IP
        :return:
        """
        if not user or not ip:
            raise Exception("user或ip不能为空")
